home *** CD-ROM | disk | FTP | other *** search
- /*
- *=============================================================================
- * tSippObj.c
- *-----------------------------------------------------------------------------
- * Tcl commands to manage SIPP objects.
- *-----------------------------------------------------------------------------
- * Copyright 1992 Mark Diekhans
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies. Mark Diekhans makes
- * no representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *-----------------------------------------------------------------------------
- * $Id: tSippObj.c,v 2.0 1992/11/02 03:56:26 markd Rel $
- *=============================================================================
- */
-
- #include "tSippInt.h"
-
- /*
- * Internal function prototypes.
- */
- static Object *
- ObjectHandleCmdSetup _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- int argc,
- char **argv));
-
- static Object *
- ObjectAxisRotSetup _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- int argc,
- char **argv,
- double *anglePtr));
-
- /*=============================================================================
- * TSippBindObjectToHandle --
- * Assigns a handle to the specified object.
- * Parameters:
- * o tSippGlobPtr (I) - Pointer to the Tcl SIPP globals. The handle is
- * returned in interp->result.
- * o objectPtr (I) - A pointer to the object.
- *-----------------------------------------------------------------------------
- */
- void
- TSippBindObjectToHandle (tSippGlobPtr, objectPtr)
- tSippGlob_pt tSippGlobPtr;
- Object *objectPtr;
- {
- Object **objectEntryPtr;
-
- objectEntryPtr = (Object **)
- Tcl_HandleAlloc (tSippGlobPtr->objectTblPtr,
- tSippGlobPtr->interp->result);
- *objectEntryPtr = objectPtr;
-
- } /* TSippBindObjectToHandle */
-
- /*=============================================================================
- * TSippObjectHandleToPtr --
- * Utility procedure to convert an object handle to an object pointer.
- * For use of by functions outside of this module. Checks for magic handle
- * "WORLD".
- *
- * Parameters:
- * o tSippGlobPtr (I) - A pointer to the Tcl SIPP global structure.
- * o handle (I) - A object handle.
- * Returns:
- * A pointer to the object, or NULL if an error occured.
- *-----------------------------------------------------------------------------
- */
- Object *
- TSippObjectHandleToPtr (tSippGlobPtr, handle)
- tSippGlob_pt tSippGlobPtr;
- char *handle;
- {
- Object **objectEntryPtr;
-
- if ((handle [0] == 'W') && (STREQU (handle, "WORLD")))
- return sipp_world;
-
- objectEntryPtr = (Object **)
- Tcl_HandleXlate (tSippGlobPtr->interp,
- tSippGlobPtr->objectTblPtr, handle);
- if (objectEntryPtr == NULL)
- return NULL;
- return *objectEntryPtr;
-
- } /* TSippObjectHandleToPtr */
-
- /*=============================================================================
- * ObjectHandleCmdSetup --
- * Utility procedure for the commands that take a single argument of an
- * object handle. Validates argv and retrieves the handle table entry.
- *
- * Parameters:
- * o tSippGlobPtr (I) - A pointer to the Tcl SIPP global structure.
- * o argc, argv (I) - Command argument vector.
- * Returns:
- * A pointer to the object associated with the handle or NULL and an error
- * in tSippGlobPtr->interp->result if an error occurs.
- *-----------------------------------------------------------------------------
- */
- static Object *
- ObjectHandleCmdSetup (tSippGlobPtr, argc, argv)
- tSippGlob_pt tSippGlobPtr;
- int argc;
- char **argv;
- {
-
- if (argc != 2) {
- Tcl_AppendResult (tSippGlobPtr->interp, "wrong # args: ", argv [0],
- " objecthandle", (char *) NULL);
- return NULL;
- }
- return TSippObjectHandleToPtr (tSippGlobPtr, argv [1]);
-
- } /* ObjectHandleCmdSetup */
-
- /*=============================================================================
- * SippObjectCreate --
- * Implements the command:
- * SippObjectCreate
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectCreate (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- if (argc != 1) {
- Tcl_AppendResult (interp, "wrong # args: ", argv[0], (char *) NULL);
- return TCL_ERROR;
- }
- TSippBindObjectToHandle ((tSippGlob_pt) clientData, object_create ());
- return TCL_OK;
-
- } /* SippObjectCreate */
-
- /*=============================================================================
- * SippObjectDelete --
- * Implements the command:
- * SippObjectDelete objectlist
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectDelete (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- int idx;
- handleList_t objectList;
- handleList_t objectEntryList;
-
- if (argc != 2) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objectlist", (char *) NULL);
- return TCL_ERROR;
- }
- if (!TSippHandleListConvert (tSippGlobPtr, tSippGlobPtr->objectTblPtr,
- argv [1], &objectList, &objectEntryList))
- return TCL_ERROR;
-
- for (idx = 0; idx < objectList.len; idx++) {
- object_delete ((Object *) objectList.ptr [idx]);
- Tcl_HandleFree (tSippGlobPtr->objectTblPtr, objectEntryList.ptr [idx]);
- }
-
- TSippHandleListFree (&objectList);
- TSippHandleListFree (&objectEntryList);
- return TCL_OK;
-
- } /* SippObjectDelete */
-
- /*=============================================================================
- * SippObjectInstance --
- * Implements the command:
- * SippObjectInstance objecthandle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectInstance (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- Object *objectPtr;
-
- objectPtr = ObjectHandleCmdSetup ((tSippGlob_pt) clientData, argc, argv);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- TSippBindObjectToHandle ((tSippGlob_pt) clientData,
- object_instance (objectPtr));
- return TCL_OK;
-
- } /* SippObjectInstance */
-
- /*=============================================================================
- * SippObjectDup --
- * Implements the command:
- * SippObjectDup objecthandle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectDup (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- Object *objectPtr;
-
- objectPtr = ObjectHandleCmdSetup ((tSippGlob_pt) clientData, argc, argv);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- TSippBindObjectToHandle ((tSippGlob_pt) clientData,
- object_dup (objectPtr));
- return TCL_OK;
-
- } /* SippObjectDup */
-
- /*=============================================================================
- * SippObjectDeepDup --
- * Implements the command:
- * SippObjectDeepDup objecthandle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectDeepDup (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- Object *objectPtr;
-
- objectPtr = ObjectHandleCmdSetup ((tSippGlob_pt) clientData, argc, argv);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- TSippBindObjectToHandle ((tSippGlob_pt) clientData,
- object_deep_dup (objectPtr));
- return TCL_OK;
-
- } /* SippObjectDeepDup */
-
- /*=============================================================================
- * SippObjectGetTransf --
- * Implements the command:
- * SippObjectGetTransf objecthandle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectGetTransf (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- Transf_mat matrix;
-
- objectPtr = ObjectHandleCmdSetup ((tSippGlob_pt) clientData, argc, argv);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- object_get_transf (objectPtr, &matrix);
- Tcl_SetResult (interp, TSippFormatMatrix (&matrix), TCL_DYNAMIC);
-
- return TCL_OK;
-
- } /* SippObjectGetTransf */
-
- /*=============================================================================
- * SippObjectSetTransf --
- * Implements the command:
- * SippObjectSetTransf objectlist matrix
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectSetTransf (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Transf_mat matrix;
- Object *objectPtr;
-
- if (argc != 3) {
- Tcl_AppendResult (tSippGlobPtr->interp, "wrong # args: ", argv [0],
- " objectlist matrix", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData,
- argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippConvertMatrix (tSippGlobPtr, argv [2], &matrix))
- return TCL_ERROR;
-
- object_set_transf (objectPtr, &matrix);
-
- return TCL_OK;
-
- } /* SippObjectSetTransf */
-
- /*=============================================================================
- * SippObjectClearTransf --
- * Implements the command:
- * SippObjectClearTransf object
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectClearTransf (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
-
- if (argc != 2) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objectlist", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData,
- argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- object_clear_transf (objectPtr);
-
- return TCL_OK;
-
- } /* SippObjectClearTransf */
-
- /*=============================================================================
- * SippObjectTransform --
- * Implements the command:
- * SippObjectTransform objectlist matrix
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectTransform (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Transf_mat matrix;
- Object *objectPtr;
-
- if (argc != 3) {
- Tcl_AppendResult (tSippGlobPtr->interp, "wrong # args: ", argv [0],
- " objectlist matrix", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData,
- argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippConvertMatrix (tSippGlobPtr, argv [2], &matrix))
- return TCL_ERROR;
-
- object_set_transf (objectPtr, &matrix);
-
- return TCL_OK;
-
- } /* SippObjectTransform */
-
- /*=============================================================================
- * SippObjectAddSurface --
- * Implements the command:
- * SippObjectAddSurface objecthandle surfacelist
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectAddSurface (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- int idx;
- handleList_t surfaceList;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle surfacelist", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData,
- argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippHandleListConvert (tSippGlobPtr, tSippGlobPtr->surfaceTblPtr,
- argv [2], &surfaceList, NULL))
- return TCL_ERROR;
-
- for (idx = 0; idx < surfaceList.len; idx++)
- object_add_surface (objectPtr, (Surface *) (surfaceList.ptr [idx]));
-
- TSippHandleListFree (&surfaceList);
- return TCL_OK;
-
- } /* SippObjectAddSurface */
-
- /*=============================================================================
- * SippObjectSubSurface --
- * Implements the command:
- * SippObjectSubSurface objecthandle surfacelist
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectSubSurface (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- int idx;
- handleList_t surfaceList;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle surfacelist", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData,
- argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippHandleListConvert (tSippGlobPtr, tSippGlobPtr->surfaceTblPtr,
- argv [2], &surfaceList, NULL))
- return TCL_ERROR;
-
- for (idx = 0; idx < surfaceList.len; idx++)
- object_sub_surface (objectPtr, (Surface *) (surfaceList.ptr [idx]));
-
- TSippHandleListFree (&surfaceList);
- return TCL_OK;
-
- } /* SippObjectSubSurface */
-
- /*=============================================================================
- * SippObjectAddSubobj --
- * Implements the command:
- * SippObjectAddSubobj objecthandle subobjlist
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectAddSubobj (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- int idx;
- handleList_t subObjList;;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle subobjlist", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData, argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- if (!TSippHandleListConvert (tSippGlobPtr, tSippGlobPtr->objectTblPtr,
- argv [2], &subObjList, NULL))
- return TCL_ERROR;
- for (idx = 0; idx < subObjList.len; idx++)
- object_add_subobj (objectPtr, (Object *) (subObjList.ptr [idx]));
-
- TSippHandleListFree (&subObjList);
-
- return TCL_OK;
-
- } /* SippObjectAddSubobj */
-
- /*=============================================================================
- * SippObjectSubSubobj --
- * Implements the command:
- * SippObjectSubSubobj objecthandle subobjlist
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectSubSubobj (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- int idx;
- handleList_t subObjList;;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle subobjlist", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr ((tSippGlob_pt) clientData, argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- if (!TSippHandleListConvert (tSippGlobPtr, tSippGlobPtr->objectTblPtr,
- argv [2], &subObjList, NULL))
- return TCL_ERROR;
- for (idx = 0; idx < subObjList.len; idx++)
- object_sub_subobj (objectPtr, (Object *) (subObjList.ptr [idx]));
-
- TSippHandleListFree (&subObjList);
-
- return TCL_OK;
-
- } /* SippObjectSubSubobj */
-
- /*=============================================================================
- * ObjectAxisRotSetup --
- * Process parameters for the commands to rotate an object around an axis.
- * These commands have the arguments: objecthandle angle
- * Parameters:
- * o tSippGlobPtr (I) - Pointer to the Tcl SIPP globals.
- * o argc, argv (I) - The arguments to the command.
- * o anglePtr (O) - The angle to rotate the object is returned here.
- * Returns:
- * A pointer to the object or NULL if an error occured.
- *-----------------------------------------------------------------------------
- */
- static Object *
- ObjectAxisRotSetup (tSippGlobPtr, argc, argv, anglePtr)
- tSippGlob_pt tSippGlobPtr;
- int argc;
- char **argv;
- double *anglePtr;
- {
- Object *objectPtr;
-
- if (argc != 3) {
- Tcl_AppendResult (tSippGlobPtr->interp, "wrong # args: ", argv [0],
- " object angle", (char *) NULL);
- return NULL;
- }
- objectPtr = TSippObjectHandleToPtr (tSippGlobPtr, argv [1]);
- if (objectPtr == NULL)
- return NULL;
- if (!TSippConvertAngleRad (tSippGlobPtr, argv [2], anglePtr))
- return NULL;
-
- return objectPtr;
-
- } /* ObjectAxisRotSetup */
-
- /*=============================================================================
- * SippObjectRotateX --
- * Implements the command:
- * SippObjectRotateX object angle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectRotateX (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- double angle;
-
- objectPtr = ObjectAxisRotSetup ((tSippGlob_pt) clientData, argc, argv,
- &angle);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- object_rot_x (objectPtr, angle);
- return TCL_OK;
-
- } /* SippObjectRotateX */
-
- /*=============================================================================
- * SippObjectRotateY --
- * Implements the command:
- * SippObjectRotateY object angle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectRotateY (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- double angle;
-
- objectPtr = ObjectAxisRotSetup ((tSippGlob_pt) clientData, argc, argv,
- &angle);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- object_rot_y (objectPtr, angle);
- return TCL_OK;
-
- } /* SippObjectRotateY */
-
- /*=============================================================================
- * SippObjectRotateZ --
- * Implements the command:
- * SippObjectRotateZ object angle
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectRotateZ (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- double angle;
-
- objectPtr = ObjectAxisRotSetup ((tSippGlob_pt) clientData, argc, argv,
- &angle);
- if (objectPtr == NULL)
- return TCL_ERROR;
-
- object_rot_z (objectPtr, angle);
- return TCL_OK;
-
- } /* SippObjectRotateZ */
-
- /*=============================================================================
- * SippObjectRotate --
- * Implements the command:
- * SippObjectRotate objecthandle point vector angle
- *
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectRotate (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- Vector point, vector;
- double angle;
-
- if (argc != 5) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle point vector angle", (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr (tSippGlobPtr, argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippConvertVertex (tSippGlobPtr, argv [2], &point))
- return TCL_ERROR;
- if (!TSippConvertVertex (tSippGlobPtr, argv [3], &vector))
- return TCL_ERROR;
- if (!TSippConvertAngleRad (tSippGlobPtr, argv [4], &angle))
- return TCL_ERROR;
-
- object_rot (objectPtr, &point, &vector, angle);
-
- return TCL_OK;
-
- } /* SippObjectRotate */
-
- /*=============================================================================
- * SippObjectScale --
- * Implements the command:
- * SippObjectScale objecthandle factor|{xfactor yfactor zfactor}
- *
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectScale (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- Vector scale;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle factor|{xfactor yfactor zfactor}",
- (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr (tSippGlobPtr, argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- /*
- * Scale can be a list or a single factor. If it contains any white space
- * assume its a list.
- */
- if (strpbrk (argv [2], " \f\t\n\r\v") == NULL) {
- if (Tcl_GetDouble (interp, argv [2], &scale.x) != TCL_OK)
- return TCL_ERROR;
- scale.y = scale.z = scale.x;
- } else {
- if (!TSippConvertVertex (tSippGlobPtr, argv [2], &scale))
- return TCL_ERROR;
- }
-
- object_scale (objectPtr, scale.x, scale.y, scale.z);
-
- return TCL_OK;
-
- } /* SippObjectScale */
-
- /*=============================================================================
- * SippObjectMove --
- * Implements the command:
- * SippObjectMove objecthandle {xdist ydist zdist}
- *
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippObjectMove (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- Object *objectPtr;
- Vector translation;
-
- if (argc != 3) {
- Tcl_AppendResult (interp, "wrong # args: ", argv [0],
- " objecthandle {xdist ydist zdist}",
- (char *) NULL);
- return TCL_ERROR;
- }
- objectPtr = TSippObjectHandleToPtr (tSippGlobPtr, argv [1]);
- if (objectPtr == NULL)
- return TCL_ERROR;
- if (!TSippConvertVertex (tSippGlobPtr, argv [2], &translation))
- return TCL_ERROR;
-
- object_move (objectPtr, translation.x, translation.y, translation.z);
-
- return TCL_OK;
-
- } /* SippObjectMove */
-
- /*=============================================================================
- * TSippObjectInit --
- * Initialized the object commands, including creating the object table.
- *
- * Parameters:
- * o tSippGlobP (I) - Pointer to the top level global data structure.
- *-----------------------------------------------------------------------------
- */
- void
- TSippObjectInit (tSippGlobPtr)
- tSippGlob_pt tSippGlobPtr;
- {
- static tSippTclCmdTbl_t cmdTable [] = {
- {"SippObjectCreate", SippObjectCreate},
- {"SippObjectDelete", SippObjectDelete},
- {"SippObjectInstance", SippObjectInstance},
- {"SippObjectDup", SippObjectDup},
- {"SippObjectDeepDup", SippObjectDeepDup},
- {"SippObjectGetTransf", SippObjectGetTransf},
- {"SippObjectSetTransf", SippObjectSetTransf},
- {"SippObjectClearTransf", SippObjectClearTransf},
- {"SippObjectTransform", SippObjectTransform},
- {"SippObjectDelete", SippObjectDelete},
- {"SippObjectAddSurface", SippObjectAddSurface},
- {"SippObjectSubSurface", SippObjectSubSurface},
- {"SippObjectAddSubobj", SippObjectAddSubobj},
- {"SippObjectSubSubobj", SippObjectSubSubobj},
- {"SippObjectRotateX", SippObjectRotateX},
- {"SippObjectRotateY", SippObjectRotateY},
- {"SippObjectRotateZ", SippObjectRotateZ},
- {"SippObjectRotate", SippObjectRotate},
- {"SippObjectScale", SippObjectScale},
- {"SippObjectMove", SippObjectMove},
- {NULL, NULL}
- };
-
- tSippGlobPtr->objectTblPtr =
- Tcl_HandleTblInit ("object", sizeof (Object *), 24);
-
- TSippInitCmds (tSippGlobPtr, cmdTable);
-
- } /* TSippObjectInit */
-